extends "../../azurlane_ctrl/AzurItem.gd"
func init():
	.init()
	name = "[特殊]钓鱼竿"
	info = "若佩戴者存活至回合结束，则有概率钓起来一些东西\n可能钓出的产物：稀有装备、普通装备、舰载机......"
	price = 300
	
func _connect():
	._connect()
	if masCha.id == "merchant":
		delFromCha()
		return
	sys.main.connect("onBattleEnd",self,"onBattleEnd")
	masCha.connect("onDeath", self, "onDeath")

var flag = true

#稀有装备、舰载机、普通装备、轮空
var rnds = [4, 10, 8, 78]
func onBattleEnd():
	if flag and utils.inBattle(masCha):
		var rnd = sys.rndRan(1, 100)
		if rnd <= rnds[0]:
			print("钓鱼成功：获得稀有装备")
			sys.main.player.addItem(sys.newItem(sys.rndListItem(itemData.rares)))
		elif rnd <= rnds[0] + rnds[1]:
			print("钓鱼成功：获得舰载机")
			var item = sys.newItem("i_ex_equip_plane")
			item.postInit(false)
			sys.main.player.addItem(item)
		elif rnd <= rnds[0] + rnds[1] + rnds[2]:
			print("钓鱼成功：获得普通装备")
			sys.main.player.addItem(sys.newItem(itemData.rndPool.rndItem().id))
	flag = true		

func onDeath(atkInfo):
	if masCha.isDeath:
		flag = false
